import * as Icons from "@ant-design/icons";
import { FC } from "react";
import { IconProvider } from "@ant-design/icons";

export type IconName = keyof typeof Icons;

interface IconProps {
  iconName: IconName;
  style?: React.CSSProperties;
}

export const IconElement: FC<IconProps> = ({ iconName, style }) => {
  const IconComponent = Icons[iconName];
  return (
    <IconProvider value={{}}>
      {IconComponent && (
        <IconComponent style={{ fontSize: 28, color: "white", ...style }} />
      )}
    </IconProvider>
  );
};
